`
https://leetcode.cn/problems/peak-index-in-a-mountain-array/
`

/**
 * @param {number[]} arr
 * @return {number}
 */
var peakIndexInMountainArray = function (arr) {
  let left = 0, right = arr.length - 1
  while (left <= right) {
    const mid = left + Math.floor((right - left) / 2)
    // 如果走势上行，说明右边有一个峰值，收缩左边界
    if (arr[mid] < arr[mid + 1]) {
      left = mid + 1
    }
    // 如果走势下行，说明左边有一个峰值，收缩右边界
    else {
      right = mid - 1
    }
  }
  return left
};